/* $Header: pi_aux.c,v 2.2 01/10/02 10:27:55 przybyls Exp $ */

/***********************************************************************/
/*                                                                     */
/*                  Copyright Hewlett-Packard Co. 1991                 */
/*                                                                     */
/***********************************************************************/

/***********************************************************************/
/* MODULE NAME:                                                        */
/* ============                                                        */
/*                                                                     */
/* Author:                                                             */
/*                                                                     */
/* MODULE PURPOSE:                                                     */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/***********************************************************************/


/*****************************/
/*   GLOBAL INCLUDE FILES    */
/*****************************/


#include <typedefs.h>
#include <error.h>
#include <p_wkfile.h>
#include <wkfile.h>
#include <i_op.h>
#include <p_status.h>
#include <list_mgmt.h>
#include <pcb_defs.h>
#include <ramps.h>         /* needed for status.h */
#include <zone_config.h>   /* needed for status.h */
#include <zone_status.h>   /* needed for status.h */
#include <status.h> /* pull in definition of Oven_Table */
#include <run_ui.h>
#include <math.h>
#include <zone_ui.h>     /* to get time <--> millisec conversions */
#include <exception.h>   /* to use SetException */
#include <err_handler.h> /* to use SetException */
#include <glp.h>
#include <clock_ui.h>
#include <keyboard.h>

/*****************************/
/*   LOCAL INCLUDE FILES     */
/*****************************/

#include "proto.h"

/*****************************/
/*   GLOBAL VARIABLES        */
/*****************************/


/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/


/*****************************/
/*   LOCAL DEFINES           */
/*****************************/


/*****************************/
/*   STATIC VARIABLES        */
/*****************************/


/*****************************/
/*   IMPLEMENT SECTION       */
/*****************************/
/**begin_proto**/
#pragma SECTION PROG=rom3
/**end_proto**/

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

INT32 GetAuxPresActual( pAUX_STATUS status )

/**end_proto**/
{

    U_INT16 Pntp;

    if (( status->Ready.Pres.State == IN_CONTROL_ ) || ( status->Ready.Pres.State == NOT_READY_DELAY ))
    {
         Pntp = status->Delayed_NTP_Aux_Pres_Setpt;  /* revisit is this ntp adjusted? */
    }
    else
    {
         Pntp = status->NTP_Adjusted_Current_Pressure;
    }

    return ConvertPresIuToDisplay ( Pntp, status->Dcm2_Per_IU );

}

/**begin_proto**/

INT32 GetAuxPresSetpt( pAUX_STATUS status )

/**end_proto**/
{
    return ConvertPresIuToDisplay ( status->Delayed_NTP_Aux_Pres_Setpt, status->Dcm2_Per_IU );
}



/**begin_proto**/

INT32 DcGetAuxPresActual( pAUX_STATUS status )

/**end_proto**/
{
    return ConvertPresIuToDcu ( status->NTP_Adjusted_Current_Pressure, status->Dcm2_Per_IU );
}



/**begin_proto**/

INT32 DcGetAuxPresSetpt( pAUX_STATUS status )

/**end_proto**/
{
    return ConvertPresIuToDcu ( status->Delayed_NTP_Aux_Pres_Setpt, status->Dcm2_Per_IU );
}



/**begin_proto**/

UI_ERR ValidateAuxPresSetpt ( INT32 setpt , pAUX_STATUS status )

/**end_proto**/
{

      if ( !PneuAuxPresent() )               return NOT_ALLOWED;

      if ( setpt < 0 )                       return PARAM_TOO_SMALL;
      if ( setpt > GetAuxMaxPres( status ) ) return PARAM_TOO_LARGE;

      return OK;
}

/**begin_proto**/

UI_ERR SetAuxPresSetpt( INT32 setpt, pAUX_STATUS status )

/**end_proto**/
{

    U_INT32  setpt_iu;
    UI_ERR   validate;

    setpt_iu = ConvertPresDisplayToIu(setpt, status->Dcm2_Per_IU );

    validate = ValidateAuxPresSetpt( setpt, status );

    if (validate == OK)
    {
        LockResource( &Inst_Status.Pneu.Resource_Lock );

        ChangeAuxPresSetpt( setpt_iu, setpt, status, GetCurrentOvenTemp() );

        if (( status->Wkfile->On_Off == OFF ) && ( setpt > 0 ))
        {
              ChangeAuxState( ON, status );
        }

        ReleaseResource( &Inst_Status.Pneu.Resource_Lock );
    }

    return validate;
}

/**begin_proto**/

UI_ERR DcSetAuxPresSetpt( INT32 setpt, pAUX_STATUS status )

/**end_proto**/
{

    U_INT32  setpt_iu;
    UI_ERR   validate;


    setpt_iu = ConvertPresDcuToIu    ( setpt,    status->Dcm2_Per_IU );
    setpt    = ConvertPresIuToDisplay( setpt_iu, status->Dcm2_Per_IU );

    validate = ValidateAuxPresSetpt( setpt, status );

    if (validate == OK)
    {
        ChangeAuxPresSetpt( setpt_iu, setpt, status, GetOvenInitTemp() );
    }

    return validate;
}

/**begin_proto**/

void ChangeAuxPresSetpt( U_INT16 pres, INT32 setpt, pAUX_STATUS status, U_INT16 oven_temp )

/**end_proto**/
{

    UpdateAuxPresStatus( pres, status, status->Dcm2_Per_IU );

    if ( !RunActiveOrPostTime() )
    {
        UpdateAuxPresSetpt( pres, status, status->Dcm2_Per_IU );
    }


    status->Slam_Pres_Setpt = TRUE;
    status->Ready.Setpt_Change = TRUE;


    UpdateColumns( pres, oven_temp, status->Position, status->Dcm2_Per_IU );

    switch ( status->Position )
    {
       case AUX_3: LogSetptChange( AUX3_PRES, setpt, (INT32)GetPresUnits() );
                   break;

       case AUX_4: LogSetptChange( AUX4_PRES, setpt, (INT32)GetPresUnits() );
                   break;

       case AUX_5: LogSetptChange( AUX5_PRES, setpt, (INT32)GetPresUnits() );
                   break;
    }

}

/**begin_proto**/

void UpdateAuxPresStatus( U_INT16 setpt_iu, pAUX_STATUS status, U_INT16 dcm2_per_iu )

/**end_proto**/
{
    U_INT16 pres_iu;

    pres_iu = QuadWordMultiplyDivide( setpt_iu, dcm2_per_iu, status->Dcm2_Per_IU );


    status->Ramp_Setpt.Ramp_Pressure = QuadWordMultiplyDivide( pres_iu,
                                                               status->Dcm2_Per_IU,
                                                               status->Ramp_Setpt.Ramp_Pres_Scaling );

    if ( !RunActiveOrPostTime() )
    {
         status->Ramp_Setpt.Ramp_Pressure = QuadWordMultiplyDivide( pres_iu,
                                                                    status->Dcm2_Per_IU,
                                                                    status->Ramp_Setpt.Ramp_Pres_Scaling );
    }

    if ( ! status->Controlled_By_Column )    /* no column defined, we are truly using aux wkfile parms  */
    {
        status->Slam_Pres_Setpt = TRUE;
        status->Ready.Setpt_Change = TRUE;
    }


}

/**begin_proto**/

void UpdateAuxPresSetpt( U_INT16 setpt_iu, pAUX_STATUS status, U_INT16 dcm2_per_iu )

/**end_proto**/
{
    U_INT16 pres_iu;

    pres_iu = QuadWordMultiplyDivide( setpt_iu, dcm2_per_iu, status->Dcm2_Per_IU );

    status->Wkfile->Desired_Pressure =  pres_iu;

    SetRampInitValue( (pRAMPINFO)(status->Ramp_Info), QuadWordMultiplyDivide( pres_iu,
                                                                              status->Dcm2_Per_IU,
                                                                              status->Ramp_Setpt.Ramp_Pres_Scaling ));
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

ON_OFF GetAuxState ( pAUX_STATUS status )

/**end_proto**/
{
     if ( status->Shutdown ) return SHUTDOWN;
     else                    return status->On_Off;

}
/**begin_proto**/

ON_OFF GetAuxWkfileState ( pAUX_STATUS status )

/**end_proto**/
{
     return status->Wkfile->On_Off;

}

/**begin_proto**/

UI_ERR SetAuxState ( ON_OFF state, pAUX_STATUS status )

/**end_proto**/
{
    BIT8 setpt_changed;

    if ( !PneuAuxPresent() ) return NOT_ALLOWED;

    setpt_changed = ( status->Wkfile->On_Off != state );
    ChangeAuxState( state, status );

    if (setpt_changed)
    {
        switch ( status->Position )
        {
           case AUX_3: LogSetptChange( state == ON ? AUX3_STATE_ON : AUX3_STATE_OFF, 0, 0 );
                       break;

           case AUX_4: LogSetptChange( state == ON ? AUX4_STATE_ON : AUX4_STATE_OFF, 0, 0 );
                       break;

           case AUX_5: LogSetptChange( state == ON ? AUX5_STATE_ON : AUX5_STATE_OFF, 0, 0 );
                       break;
        }
    }

    return OK;

}

/**begin_proto**/

void ChangeAuxState ( ON_OFF state, pAUX_STATUS status )

/**end_proto**/
{

      if (( state == ON ) || ( state == OFF ))
      {
          if (( state == ON ) && ( status->Wkfile->On_Off == OFF ))
          {
             status->Ready.On = TRUE;
          }

          status->Wkfile->On_Off = state;
          status->On_Off = state;

          if ( state == OFF )
          {
                status->Filtered_Pressure_Setpt   = 0;
          }

          if ((state == ON ) && ( !status->Controlled_By_Column ))
          {
              EnableRamp( (pRAMPINFO)status->Ramp_Info );
          }
          else
          {
              DisableRamp( (pRAMPINFO)status->Ramp_Info );
          }

          if (( status->Shutdown ) && ( state == OFF ))
          {
               status->Adc_Setpt = 0;
               DownloadSetpoints ( );
          }

          if ( status->Shutdown )
          {
              status->Shutdown = FALSE;
              if ( status->Position == AUX_3 )
              {
                  ClearException( PNEU_AUX_3_SHUTDOWN );
                  QuickRestartChannel( AUX_3_MASK, 3 );
              }
              else if ( status->Position == AUX_4 )
              {
                  ClearException( PNEU_AUX_4_SHUTDOWN );
                  QuickRestartChannel( AUX_4_MASK, 3 );
              }
              else if ( status->Position == AUX_5 )
              {
                  ClearException( PNEU_AUX_5_SHUTDOWN );
                  QuickRestartChannel( AUX_5_MASK, 3 );
              }
          }
      }

    status->Slam_Pres_Setpt    = TRUE;
    status->Ready.Setpt_Change = TRUE;

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

UI_ERR DcRTTGetValidAux3Pres ( INT32 setpt, U_INT16 *pres_iu )

/**end_proto**/
{

    U_INT16  p_iu;
    INT32    p_du;
    UI_ERR   error;
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_3;

    p_iu = ConvertPresDcuToIu    ( setpt, status->Dcm2_Per_IU );
    p_du = ConvertPresIuToDisplay( p_iu, status->Dcm2_Per_IU );

    if ( (error = ValidateAuxPresSetpt( p_du, status )) == OK)
    {
         *pres_iu = p_iu;
    }

    return error;
}

/**begin_proto**/

UI_ERR DcRTTGetValidAux4Pres ( INT32 setpt, U_INT16 *pres_iu )

/**end_proto**/
{

    U_INT16  p_iu;
    INT32    p_du;
    UI_ERR   error;
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_4;

    p_iu = ConvertPresDcuToIu    ( setpt, status->Dcm2_Per_IU );
    p_du = ConvertPresIuToDisplay( p_iu, status->Dcm2_Per_IU );

    if ( (error = ValidateAuxPresSetpt( p_du, status )) == OK)
    {
         *pres_iu = p_iu;
    }

    return error;
}

/**begin_proto**/

UI_ERR DcRTTGetValidAux5Pres ( INT32 setpt, U_INT16 *pres_iu )

/**end_proto**/
{

    U_INT16  p_iu;
    INT32    p_du;
    UI_ERR   error;
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_5;

    p_iu = ConvertPresDcuToIu    ( setpt, status->Dcm2_Per_IU );
    p_du = ConvertPresIuToDisplay( p_iu, status->Dcm2_Per_IU );

    if ( (error = ValidateAuxPresSetpt( p_du, status )) == OK)
    {
         *pres_iu = p_iu;
    }

    return error;
}

/**begin_proto**/

UI_ERR RTTGetValidAux3Pres ( INT32 setpt, U_INT16 *pres_iu )

/**end_proto**/
{

    U_INT16  p_iu;
    UI_ERR   error;
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_3;

    p_iu = ConvertPresDisplayToIu( setpt, status->Dcm2_Per_IU );

    if ( (error = ValidateAuxPresSetpt( setpt, status )) == OK)
    {
         *pres_iu = p_iu;
    }

    return error;
}

/**begin_proto**/

UI_ERR RTTGetValidAux4Pres ( INT32 setpt, U_INT16 *pres_iu )

/**end_proto**/
{

    U_INT16  p_iu;
    UI_ERR   error;
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_4;

    p_iu = ConvertPresDisplayToIu( setpt, status->Dcm2_Per_IU );

    if ( (error = ValidateAuxPresSetpt( setpt, status )) == OK)
    {
         *pres_iu = p_iu;
    }

    return error;
}

/**begin_proto**/

UI_ERR RTTGetValidAux5Pres ( INT32 setpt, U_INT16 *pres_iu )

/**end_proto**/
{

    U_INT16  p_iu;
    UI_ERR   error;
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_5;

    p_iu = ConvertPresDisplayToIu( setpt, status->Dcm2_Per_IU );

    if ( (error = ValidateAuxPresSetpt( setpt, status )) == OK)
    {
         *pres_iu = p_iu;
    }

    return error;
}

/**begin_proto**/

INT32 DcRTTGetAux3PresDisplay ( U_INT16 pres_iu )

/**end_proto**/
{
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_3;

    return ConvertPresIuToDcu( pres_iu, status->Dcm2_Per_IU );
}

/**begin_proto**/

INT32 DcRTTGetAux4PresDisplay ( U_INT16 pres_iu )

/**end_proto**/
{
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_4;

    return ConvertPresIuToDcu( pres_iu, status->Dcm2_Per_IU );
}

/**begin_proto**/

INT32 DcRTTGetAux5PresDisplay ( U_INT16 pres_iu )

/**end_proto**/
{
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_5;

    return ConvertPresIuToDcu( pres_iu, status->Dcm2_Per_IU );
}

/**begin_proto**/

INT32 RTTGetAux3PresDisplay ( U_INT16 pres_iu )

/**end_proto**/
{
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_3;

    return ConvertPresIuToDisplay( pres_iu, status->Dcm2_Per_IU );
}

/**begin_proto**/

INT32 RTTGetAux4PresDisplay ( U_INT16 pres_iu )

/**end_proto**/
{
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_4;

    return ConvertPresIuToDisplay( pres_iu, status->Dcm2_Per_IU );
}

/**begin_proto**/

INT32 RTTGetAux5PresDisplay ( U_INT16 pres_iu )

/**end_proto**/
{
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_5;

    return ConvertPresIuToDisplay( pres_iu, status->Dcm2_Per_IU );
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void RTTSetAux3Pres ( INT32 p_iu )

/**end_proto**/
{
    U_INT16  oven_temp;
    INT32 setpt;
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_3;

    oven_temp = GetCurrentOvenTemp();

    setpt = ConvertPresIuToDisplay( p_iu, status->Dcm2_Per_IU );

    if (ValidateAuxPresSetpt( setpt, status ) == OK)
    {
         status->Ready.Time_Program_Change = TRUE;

         if ( status->On_Off == OFF ) status->On_Off = ON;

         status->Desired_Pressure =  p_iu;
         status->Ramp_Setpt.Ramp_Pressure = QuadWordMultiplyDivide( p_iu,
                                                               status->Dcm2_Per_IU,
                                                               status->Ramp_Setpt.Ramp_Pres_Scaling );

         UpdateColumnsStatusOnly ( p_iu, oven_temp, status->Position, status->Dcm2_Per_IU );

         status->Slam_Pres_Setpt = TRUE;
    }
}


/**begin_proto**/

void RTTSetAux4Pres ( INT32 p_iu )

/**end_proto**/
{
    U_INT16  oven_temp;
    INT32 setpt;
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_4;

    oven_temp = GetCurrentOvenTemp();

    setpt = ConvertPresIuToDisplay( p_iu, status->Dcm2_Per_IU );

    if (ValidateAuxPresSetpt( setpt, status ) == OK)
    {
         status->Ready.Time_Program_Change = TRUE;

         if ( status->On_Off == OFF ) status->On_Off = ON;

         status->Desired_Pressure =  p_iu;
         status->Ramp_Setpt.Ramp_Pressure = QuadWordMultiplyDivide( p_iu,
                                                               status->Dcm2_Per_IU,
                                                               status->Ramp_Setpt.Ramp_Pres_Scaling );

         UpdateColumnsStatusOnly ( p_iu, oven_temp, status->Position, status->Dcm2_Per_IU );

         status->Slam_Pres_Setpt = TRUE;
    }
}


/**begin_proto**/

void RTTSetAux5Pres ( INT32 p_iu )

/**end_proto**/
{
    U_INT16  oven_temp;
    INT32 setpt;
    pAUX_STATUS status;

    status = &Inst_Status.Pneu.Aux.Aux_5;

    oven_temp = GetCurrentOvenTemp();

    setpt = ConvertPresIuToDisplay( p_iu, status->Dcm2_Per_IU );

    if (ValidateAuxPresSetpt( setpt, status ) == OK)
    {
         status->Ready.Time_Program_Change = TRUE;

         if ( status->On_Off == OFF ) status->On_Off = ON;

         status->Desired_Pressure =  p_iu;
         status->Ramp_Setpt.Ramp_Pressure = QuadWordMultiplyDivide( p_iu,
                                                               status->Dcm2_Per_IU,
                                                               status->Ramp_Setpt.Ramp_Pres_Scaling );

         UpdateColumnsStatusOnly ( p_iu, oven_temp, status->Position, status->Dcm2_Per_IU );

         status->Slam_Pres_Setpt = TRUE;
    }
}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void ResetAuxPres ( pAUX_STATUS status )

/**end_proto**/
{

     status->Controlled_By_Column = SourceControlledByColumn ( status->Position );

     if ( status->Controlled_By_Column == FALSE )
     {

          status->On_Off = status->Wkfile->On_Off;

          EnableRamp( (pRAMPINFO)(&Inst_Status.Pneu.Aux.Aux_4.Ramp_Info) );

          status->Ramp_Setpt.Ramp_Pressure = QuadWordMultiplyDivide( GetRampInitValue( (pRAMPINFO)status->Ramp_Info ),
                                                                     status->Dcm2_Per_IU,
                                                                     status->Ramp_Setpt.Ramp_Pres_Scaling );
          status->Slam_Pres_Setpt = TRUE;
     }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void ResetAuxPressures ( void )

/**end_proto**/
{

     pAUX_STATUS status;


     status = &Inst_Status.Pneu.Aux.Aux_3;

     status->On_Off = status->Wkfile->On_Off;

     status->Ramp_Setpt.Ramp_Pressure = QuadWordMultiplyDivide( Active_Wkfile.Pneu.Aux_3.Desired_Pressure,
                                                                status->Dcm2_Per_IU,
                                                                status->Ramp_Setpt.Ramp_Pres_Scaling );
     status->Slam_Pres_Setpt = TRUE;



     status = &Inst_Status.Pneu.Aux.Aux_4;

     status->On_Off = status->Wkfile->On_Off;

     status->Ramp_Setpt.Ramp_Pressure = QuadWordMultiplyDivide( Active_Wkfile.Pneu.Aux_4.Desired_Pressure,
                                                                status->Dcm2_Per_IU,
                                                                status->Ramp_Setpt.Ramp_Pres_Scaling );
     status->Slam_Pres_Setpt = TRUE;



     status = &Inst_Status.Pneu.Aux.Aux_5;

     status->On_Off = status->Wkfile->On_Off;

     status->Ramp_Setpt.Ramp_Pressure = QuadWordMultiplyDivide( Active_Wkfile.Pneu.Aux_5.Desired_Pressure,
                                                                status->Dcm2_Per_IU,
                                                                status->Ramp_Setpt.Ramp_Pres_Scaling );
     status->Slam_Pres_Setpt = TRUE;



}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 PneuAuxPresent ( void )

/**end_proto**/
{

    return Inst_Config.Pneu.Aux_3.Functional ||
           Inst_Config.Pneu.Aux_4.Functional ||
           Inst_Config.Pneu.Aux_5.Functional;

}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

INT32 GetAuxMaxPres( pAUX_STATUS status )

/**end_proto**/
{

   return ConvertPresIuToDisplay ( status->P_Sensor_Range, status->Dcm2_Per_IU );

}
/**begin_proto**/

INT32 GetAuxMaxPresIu( pAUX_STATUS status, U_INT16 dcm2_per_iu )

/**end_proto**/
{

   return QuadWordMultiplyDivide ( status->P_Sensor_Range, status->Dcm2_Per_IU, dcm2_per_iu );

}

/**begin_proto**/
INT32 GetAuxRealMaxPresIu( pAUX_STATUS status, U_INT16 dcm2_per_iu )

/**end_proto**/
{

   return QuadWordMultiplyDivide ( status->Real_PS_Range, status->Dcm2_Per_IU, dcm2_per_iu );

}

/**begin_proto**/

INT32 DcGetAuxMaxPres( pAUX_STATUS status )

/**end_proto**/
{

   if ( !PneuAuxPresent() ) return 0;

   return ConvertPresIuToDcu ( status->P_Sensor_Range, status->Dcm2_Per_IU );

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

GAS_TYPE GetAuxGasType ( pAUX_STATUS status )

/**end_proto**/
{

   return status->Config->Gas_Type;

}

/**begin_proto**/

UI_ERR ValidAuxGasType(  GAS_TYPE gas )

/**end_proto**/
{
    switch ( gas )
    {

       case Air:
       case H2:
       case He:
       case N2:
       case ArMe: return OK;

       default:  return INVALID_PARAM;
    }
}

/**begin_proto**/

UI_ERR ValidateAuxGasType( pAUX_STATUS status, GAS_TYPE gas )

/**end_proto**/
{
    if (gas != Air ) return ValidAuxGasType(gas) ;
    if (
        ( Inst_Config.Pneu.Column_1.Source == status->Position ) ||
        ( Inst_Config.Pneu.Column_2.Source == status->Position )
       ) return INVALID_PARAM;
    return OK;
}

/**begin_proto**/

UI_ERR SetAuxGasType ( GAS_TYPE gas, pAUX_STATUS status )

/**end_proto**/
{
   UI_ERR error;


    if ( !PneuAuxPresent() ) return NOT_ALLOWED;

    if ( (error = ValidateAuxGasType ( status, gas )) != OK )  return error;

    /* status->Config->Gas_Type = gas;  deleted as per PVCS#277       */

    SendAuxGasChangeRequest( status, gas );

    if ( !DoingMethodInstall() ) ReconfigurePneu();

    switch ( gas )
    {
     case He: switch ( status->Position )
              {
                case AUX_3: LogSetptChange( AUX3_GAS_HE, 0, 0 );
                            break;
                case AUX_4: LogSetptChange( AUX4_GAS_HE, 0, 0 );
                            break;
                case AUX_5: LogSetptChange( AUX5_GAS_HE, 0, 0 );
                            break;
               }
               break;

     case H2: switch ( status->Position )
              {
                case AUX_3: LogSetptChange( AUX3_GAS_H2, 0, 0 );
                            break;
                case AUX_4: LogSetptChange( AUX4_GAS_H2, 0, 0 );
                            break;
                case AUX_5: LogSetptChange( AUX5_GAS_H2, 0, 0 );
                            break;
               }
               break;

     case N2: switch ( status->Position )
              {
                case AUX_3: LogSetptChange( AUX3_GAS_N2, 0, 0 );
                            break;
                case AUX_4: LogSetptChange( AUX4_GAS_N2, 0, 0 );
                            break;
                case AUX_5: LogSetptChange( AUX5_GAS_N2, 0, 0 );
                            break;
               }
               break;

     case ArMe: switch ( status->Position )
              {
                case AUX_3: LogSetptChange( AUX3_GAS_ARME, 0, 0 );
                            break;
                case AUX_4: LogSetptChange( AUX4_GAS_ARME, 0, 0 );
                            break;
                case AUX_5: LogSetptChange( AUX5_GAS_ARME, 0, 0 );
                            break;
               }
               break;

     case Air: switch ( status->Position )
              {
                case AUX_3: LogSetptChange( AUX3_GAS_AIR, 0, 0 );
                            break;
                case AUX_4: LogSetptChange( AUX4_GAS_AIR, 0, 0 );
                            break;
                case AUX_5: LogSetptChange( AUX5_GAS_AIR, 0, 0 );
                            break;
               }
               break;

      default: return INVALID_PARAM;
    }

    status->Ready.Setpt_Change = TRUE;

    return error;
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

INT32 GetAuxPresEquibTime ( pAUX_STATUS status )

/**end_proto**/
{
    return  MilliSecsToTime( status->Wkfile->Pres_Equib_Time );
}

/**begin_proto**/

INT32 DcGetAuxPresEquibTime ( pAUX_STATUS status )

/**end_proto**/
{
    return  status->Wkfile->Pres_Equib_Time;
}

/**begin_proto**/

UI_ERR ValidateAuxPresEquibTime ( INT32 time, pAUX_STATUS status )

/**end_proto**/
{

     (void) time;
     (void) status;

     if ( !PneuAuxPresent() ) return NOT_ALLOWED;

     return CheckTimeSetpt( time );

}


/**begin_proto**/

UI_ERR DcSetAuxPresEquibTime( INT32 time, pAUX_STATUS status )

/**end_proto**/
{
    UI_ERR validate;

    validate = ValidateAuxPresEquibTime( time, status );

    if ( validate == OK )
    {
         ChangeAuxPresEquibTime ( time, status );
    }

    return validate;
}


/**begin_proto**/

UI_ERR SetAuxPresEquibTime( INT32 time, pAUX_STATUS status )

/**end_proto**/
{
    UI_ERR validate;

    validate = ValidateAuxPresEquibTime( time, status );

    if ( validate == OK )
    {
         LockResource( &Inst_Status.Pneu.Resource_Lock );

         ChangeAuxPresEquibTime ( time, status );

         ReleaseResource( &Inst_Status.Pneu.Resource_Lock );
    }

    return validate;
}


/**begin_proto**/

void ChangeAuxPresEquibTime( INT32 time, pAUX_STATUS status )

/**end_proto**/
{

   status->Wkfile->Pres_Equib_Time = TimeToMilliSecs( time );

    status->Ready.Setpt_Change = TRUE;

    switch ( status->Position )
    {
       case AUX_3: LogSetptChange( AUX3_PRES_EQUIB_TIME, time, 0 );
                   break;

       case AUX_4: LogSetptChange( AUX4_PRES_EQUIB_TIME, time, 0 );
                   break;

       case AUX_5: LogSetptChange( AUX5_PRES_EQUIB_TIME, time, 0 );
                   break;
    }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

INT32 DcGetAuxCalPresGain ( pAUX_STATUS status )

/**end_proto**/
{
    return SignedQuadWordMultiplyDivide( CALIB_GAIN_DC_SCALE,
                                         status->Calib.Gain - CALIB_GAIN_SCALING,
                                         CALIB_GAIN_SCALING );
}

/**begin_proto**/

INT32 GetAuxCalPresValue( pAUX_STATUS status )

/**end_proto**/
{

      return ConvertPresIuToDisplay ( status->Calib.Value, status->Dcm2_Per_IU );
}

/**begin_proto**/

INT32 DcGetAuxCalPresValue ( pAUX_STATUS status )

/**end_proto**/
{

      return ConvertPresIuToDcu ( status->Calib.Value, status->Dcm2_Per_IU );
}

/**begin_proto**/

INT32 GetAuxCalPresZero ( pAUX_STATUS status )

/**end_proto**/
{

    pAUXILIARY_STATUS astatus;
    pPRES_SENSOR_STRUCT sensor;
    U_INT16 temp;

    if ( !PneuAuxPresent() ) return 0;

    astatus = &Inst_Status.Pneu.Aux;

    switch ( status->Position )
    {
       default:
       case AUX_3: sensor = &astatus->Tcomp_Tables->Aux_3; break;
       case AUX_4: sensor = &astatus->Tcomp_Tables->Aux_4; break;
       case AUX_5: sensor = &astatus->Tcomp_Tables->Aux_5; break;
    }

    temp = astatus->Tcomp_Tables->Thermistor.Module_Temperature;

    return GetPresOffsetDispUnits ( status->Calib.Offset, status->Dcm2_Per_IU, sensor, temp );

}

/**begin_proto**/

INT32 DcGetAuxCalPresZero ( pAUX_STATUS status )

/**end_proto**/
{
    pAUXILIARY_STATUS astatus;
    pPRES_SENSOR_STRUCT sensor;
    U_INT16 temp;

    if ( !PneuAuxPresent() ) return 0;

    astatus = &Inst_Status.Pneu.Aux;

    switch ( status->Position )
    {
       default:
       case AUX_3: sensor = &astatus->Tcomp_Tables->Aux_3; break;
       case AUX_4: sensor = &astatus->Tcomp_Tables->Aux_4; break;
       case AUX_5: sensor = &astatus->Tcomp_Tables->Aux_5; break;
    }

    temp = astatus->Tcomp_Tables->Thermistor.Module_Temperature;

    return GetPresOffsetDcUnits ( status->Calib.Offset, status->Dcm2_Per_IU, sensor, temp );

}

/**begin_proto**/

UI_ERR SetAuxCalPresZero ( pAUX_STATUS status )

/**end_proto**/
{
   UI_ERR error;

   LockResource( &Inst_Status.Pneu.Resource_Lock );

   error = ChangeAuxCalPresZero ( status );

   ReleaseResource( &Inst_Status.Pneu.Resource_Lock );

   return error;
}

/**begin_proto**/

UI_ERR DcSetAuxCalPresZero ( pAUX_STATUS status )

/**end_proto**/
{
   UI_ERR error;

   error = ChangeAuxCalPresZero ( status );

   return error;
}

/**begin_proto**/

UI_ERR ChangeAuxCalPresZero ( pAUX_STATUS status )

/**end_proto**/
{
    pAUXILIARY_STATUS astatus;
    pPRES_SENSOR_STRUCT sensor;
    U_INT16 temp;
    INT16 offset;
    UI_ERR error;

    if ( !PneuAuxPresent() ) return NOT_ALLOWED;

    astatus = &Inst_Status.Pneu.Aux;

    switch ( status->Position )
    {
       default:
       case AUX_3: sensor = &astatus->Tcomp_Tables->Aux_3; break;
       case AUX_4: sensor = &astatus->Tcomp_Tables->Aux_4; break;
       case AUX_5: sensor = &astatus->Tcomp_Tables->Aux_5; break;
    }

    temp = astatus->Tcomp_Tables->Thermistor.Module_Temperature;

    offset = CalcPresCalibOffset ( status->Adc_Actual, sensor, temp );

    if ((error = ValidatePresOffset( offset, status->Dcm2_Per_IU, sensor, temp )) != OK ) return error;

    status->Calib.Offset = offset;

    SendPneuAuxCalibRequest ( );

    status->Ready.Setpt_Change = TRUE;

    switch ( status->Position )
    {
       case AUX_3: LogSetptChange( AUX3_CAL_PRES_ZERO, 0, 0 );
                   break;

       case AUX_4: LogSetptChange( AUX4_CAL_PRES_ZERO, 0, 0 );
                   break;

       case AUX_5: LogSetptChange( AUX5_CAL_PRES_ZERO, 0, 0 );
                   break;
    }

   return OK;
}

/**begin_proto**/

UI_ERR DcSetAuxFactoryCalPresZero ( )

/**end_proto**/
{
    pAUXILIARY_STATUS astatus;
    pAUX_STATUS status;
    pPRES_SENSOR_STRUCT sensor;
    U_INT16 temp;
    INT16 offset1, offset2, offset3;
    UI_ERR error1, error2, error3;

    if ( !PneuAuxPresent() ) return NOT_ALLOWED;

    astatus = &Inst_Status.Pneu.Aux;

    sensor = &astatus->Tcomp_Tables->Aux_3;
    status = &Inst_Status.Pneu.Aux.Aux_3;
    temp = astatus->Tcomp_Tables->Thermistor.Module_Temperature;
    offset1 = CalcPresCalibOffset ( status->Adc_Actual, sensor, temp );
    error1 = ValidatePresOffset( offset1, status->Dcm2_Per_IU, sensor, temp );

    sensor = &astatus->Tcomp_Tables->Aux_4;
    status = &Inst_Status.Pneu.Aux.Aux_4;
    temp = astatus->Tcomp_Tables->Thermistor.Module_Temperature;
    offset2 = CalcPresCalibOffset ( status->Adc_Actual, sensor, temp );
    error2 = ValidatePresOffset( offset2, status->Dcm2_Per_IU, sensor, temp );

    sensor = &astatus->Tcomp_Tables->Aux_5;
    status = &Inst_Status.Pneu.Aux.Aux_5;
    temp = astatus->Tcomp_Tables->Thermistor.Module_Temperature;
    offset3 = CalcPresCalibOffset ( status->Adc_Actual, sensor, temp );
    error3 = ValidatePresOffset( offset3, status->Dcm2_Per_IU, sensor, temp );

    if (( error1 == OK ) && ( error2 == OK ) && ( error3 == OK ))
    {
          Inst_Status.Pneu.Aux.Aux_3.Calib.Offset = offset1;
          Inst_Status.Pneu.Aux.Aux_4.Calib.Offset = offset2;
          Inst_Status.Pneu.Aux.Aux_5.Calib.Offset = offset3;

          Inst_Status.Pneu.Aux.Aux_3.Calib.Gain   = CALIB_GAIN_SCALING;
          Inst_Status.Pneu.Aux.Aux_4.Calib.Gain   = CALIB_GAIN_SCALING;
          Inst_Status.Pneu.Aux.Aux_5.Calib.Gain   = CALIB_GAIN_SCALING;

          Inst_Status.Pneu.Aux.Aux_3.Calib.Value  = 0;
          Inst_Status.Pneu.Aux.Aux_4.Calib.Value  = 0;
          Inst_Status.Pneu.Aux.Aux_5.Calib.Value  = 0;

          InitializeDateTime( &Inst_Status.Pneu.Aux.Calib_Date );

          status->Ready.Setpt_Change = TRUE;
          LogSetptChange( AUX3_CAL_PRES_ZERO, 0, 0 );
          LogSetptChange( AUX4_CAL_PRES_ZERO, 0, 0 );
          LogSetptChange( AUX5_CAL_PRES_ZERO, 0, 0 );

          SaveAuxFactoryCalib( &Inst_Status.Pneu.Aux );

          return OK;

    }
    else
    {
         return TEST_FAILED;
    }

}

/**begin_proto**/

UI_ERR SetAuxCalPres ( pAUX_STATUS status, INT32 pres )

/**end_proto**/
{
      UI_ERR  error;
      U_INT32 pres_iu;

      if ( !PneuAuxPresent() ) return NOT_ALLOWED;

      if ( pres <= 0 ) return PARAM_TOO_SMALL;
      if ( pres > GetAuxMaxPres(status) ) return PARAM_TOO_LARGE;

      if ( status->Filtered_Current_Pressure == 0 ) return NOT_ALLOWED;

      pres_iu = ConvertPresDisplayToIu( pres, status->Dcm2_Per_IU );

      LockResource( &Inst_Status.Pneu.Resource_Lock );

      error = ChangeAuxCalPres( status, pres, pres_iu );

      ReleaseResource( &Inst_Status.Pneu.Resource_Lock );

      return error;
}

/**begin_proto**/

UI_ERR DcSetAuxCalPres ( pAUX_STATUS status, INT32 pres )

/**end_proto**/
{

      INT32   pres_dispu;
      U_INT32 pres_iu;

      if ( !PneuAuxPresent() ) return NOT_ALLOWED;

      pres_iu = ConvertPresDcuToIu( pres, status->Dcm2_Per_IU );
      pres_dispu = ConvertPresIuToDisplay( pres_iu, status->Dcm2_Per_IU );

      if ( pres <= 0 ) return PARAM_TOO_SMALL;
      if ( pres > DcGetAuxMaxPres(status) ) return PARAM_TOO_LARGE;

      if ( status->Filtered_Current_Pressure == 0 ) return NOT_ALLOWED;

      return ChangeAuxCalPres( status, pres_dispu, pres_iu );

}

/**begin_proto**/

UI_ERR ChangeAuxCalPres ( pAUX_STATUS status, INT32 pres, U_INT32 pres_iu )

/**end_proto**/
{

    UI_ERR  error;
    U_INT16 gain;
    pAUXILIARY_STATUS astatus;
    pPRES_SENSOR_STRUCT sensor;

      if ( !PneuAuxPresent() ) return NOT_ALLOWED;

      astatus = &Inst_Status.Pneu.Aux;

      switch ( status->Position )
      {
         default:
         case AUX_3: sensor = &astatus->Tcomp_Tables->Aux_3; break;
         case AUX_4: sensor = &astatus->Tcomp_Tables->Aux_4; break;
         case AUX_5: sensor = &astatus->Tcomp_Tables->Aux_5; break;
      }

      if (!EnoughPresToCalibrate( status->Filtered_Current_Pressure,
                                  sensor,
                                  status->Dcm2_Per_IU )) return OUTSIDE_ALLOWED_RANGE;

      gain = CalcCalibGain ( status->Filtered_Current_Pressure, pres_iu, status->Calib.Gain );

      if ((error=ValidatePresCalibGain(gain))!= OK ) return error;

      status->Calib.Gain =  gain;
      status->Calib.Value = pres_iu;

      SendPneuAuxCalibRequest ( );

    status->Ready.Setpt_Change = TRUE;

    switch ( status->Position )
    {
       case AUX_3: LogSetptChange( AUX3_CAL_PRES, pres, (INT32)GetPresUnits() );
                   break;

       case AUX_4: LogSetptChange( AUX4_CAL_PRES, pres, (INT32)GetPresUnits() );
                   break;

       case AUX_5: LogSetptChange( AUX5_CAL_PRES, pres, (INT32)GetPresUnits() );
                   break;
    }

    return OK;
}

/**begin_proto**/

INT32 GetAuxMinPresReqdToCalib( pAUX_STATUS status )

/**end_proto**/
{

      pPRES_SENSOR_STRUCT sensor;
      pAUXILIARY_STATUS astatus;

      astatus = &Inst_Status.Pneu.Aux;

      switch ( status->Position )
      {
         default:
         case AUX_3: sensor = &astatus->Tcomp_Tables->Aux_3; break;
         case AUX_4: sensor = &astatus->Tcomp_Tables->Aux_4; break;
         case AUX_5: sensor = &astatus->Tcomp_Tables->Aux_5; break;
      }


      return ConvertPresIuToDisplay ( GetPresRequiredToCalibrate( sensor ), status->Dcm2_Per_IU );

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

DATETIME GetAuxCalibDate( pAUX_STATUS status )

/**end_proto**/
{

     (void) status;
     return Inst_Status.Pneu.Aux.Calib_Date;

}


/**begin_proto**/

UI_ERR ValidateAuxCalibState( pAUX_STATUS status, ON_OFF  state )

/**end_proto**/
{

/* there is a failure posible here, if multiple cmds to enable or */
/* disable calib are stacked in the gastask queue, this routine   */
/* can give false results.                                        */

    UI_ERR error;

    if ( PneuAuxPresent( ) )
    {
        if (( state == OFF ) && ( AuxUserCalibState( status ) == USER_ENABLED ))
        {
            error = OK;
        }
        else if (( state == ON ) && ( AuxUserCalibState( status ) == USER_DISABLED ))
        {
            error = OK;
        }
        else
        {
            error = INVALID_OP;
        }
    }
    else
    {
        error = NOT_ALLOWED;
    }

    return error;

}

/**begin_proto**/

UI_ERR TurnOffAuxCalib( pAUX_STATUS status )

/**end_proto**/
{
    UI_ERR error;

    if ( (error =  ValidateAuxCalibState( status, OFF )) == OK )
    {
        LockResource( &Inst_Status.Pneu.Resource_Lock );

        SendPneuAuxDisableUserRequest( );

        ReleaseResource( &Inst_Status.Pneu.Resource_Lock );
    }

    return error;
}

/**begin_proto**/

UI_ERR DcTurnOffAuxCalib( pAUX_STATUS status )

/**end_proto**/
{
    UI_ERR error;

    if ( (error =  ValidateAuxCalibState( status, OFF )) == OK )
    {
        SendPneuAuxDisableUserRequest( );
    }

    return error;
}


/**begin_proto**/

UI_ERR TurnOnAuxCalib( pAUX_STATUS status )

/**end_proto**/
{
    UI_ERR error;

    if ( (error =  ValidateAuxCalibState( status, ON )) == OK )
    {
        LockResource( &Inst_Status.Pneu.Resource_Lock );

        SendPneuAuxEnableUserRequest( );

        ReleaseResource( &Inst_Status.Pneu.Resource_Lock );
    }

    return error;
}

/**begin_proto**/

UI_ERR DcTurnOnAuxCalib( pAUX_STATUS status )

/**end_proto**/
{
    UI_ERR error;

    if ( (error =  ValidateAuxCalibState( status, ON )) == OK )
    {
        SendPneuAuxEnableUserRequest( );
    }

    return error;
}


/**begin_proto**/

UI_ERR ChangeAuxCalibState( ON_OFF  state )

/**end_proto**/
{
    UI_ERR error;

    if ( PneuAuxPresent() )
    {
        if (( state == OFF ) && ( AuxUserCalibState( &Inst_Status.Pneu.Aux.Aux_3 ) == USER_ENABLED ))
        {
            DisableAuxCalib ( &Inst_Status.Pneu.Aux );
            LogSetptChange( AUX_CAL_DISABLED, 0, 0 );
            error = OK;
        }
        else if (( state == ON ) && ( AuxUserCalibState( &Inst_Status.Pneu.Aux.Aux_3 ) == USER_DISABLED ))
        {
            EnableAuxCalib( &Inst_Status.Pneu.Aux );
            LogSetptChange( AUX_CAL_ENABLED, 0, 0 );
            error = OK;
        }
        else
        {
            error = INVALID_OP;
        }
    }
    else
    {
        error = NOT_ALLOWED;
    }

    return error;

}


/**begin_proto**/

UI_ERR DcDeleteAuxCalib ( pAUX_STATUS status )

/**end_proto**/
{
    (void) status;

       return SendDeleteAuxCalib( status );
}

/**begin_proto**/

UI_ERR DeleteAuxCalib ( pAUX_STATUS status )

/**end_proto**/
{
    UI_ERR error;

    (void) status;

    LockResource( &Inst_Status.Pneu.Resource_Lock );

    error = SendDeleteAuxCalib( status );

    ReleaseResource( &Inst_Status.Pneu.Resource_Lock );

    return error;
}

/**begin_proto**/

UI_ERR SendDeleteAuxCalib ( pAUX_STATUS status )

/**end_proto**/
{
    (void) status;

    if (!PneuAuxPresent() )                       return NOT_ALLOWED;

    if ( AuxUserCalibState( status ) == FACTORY ) return INVALID_OP;

    SendPneuAuxScratchRequest ( );

    LogSetptChange( AUX_CAL_DELETED, 0, 0 );

    Inst_Status.Pneu.Aux.Aux_3.Ready.Setpt_Change = TRUE;
    Inst_Status.Pneu.Aux.Aux_4.Ready.Setpt_Change = TRUE;
    Inst_Status.Pneu.Aux.Aux_5.Ready.Setpt_Change = TRUE;

    return OK;
}

/**begin_proto**/

CALIB_STATE AuxUserCalibState ( pAUX_STATUS status )

/**end_proto**/
{
    (void) status;

    return Inst_Status.Pneu.Aux.Calib_State;
}


/**begin_proto**/
#pragma SECTION UNDO
/**end_proto**/
